package com.zhengping.zpys.security.user.role;

import com.zhengping.zpys.security.role.RoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author chenweizuan
 * @description This is description of class
 * @version 1.0
 * @date 2020/3/28 17:19
 */
@Service
public class UserRoleServiceImpl implements UserRoleService {

    @Autowired
    UserRoleMapper userRoleMapper;

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public Integer creatUserRole(Long userId, Long roleId) {
        Integer i = 0;
        if (roleMapper.queryRoleById(roleId).getRoleId()!=null && !roleMapper.queryRoleById(roleId).getRoleId().equals("")){
            i = userRoleMapper.creatUserRole(userId, roleId);
        }
        return i;
    }

    @Override
    public Integer deleteUserRole(Long[] userIds) {
        return userRoleMapper.deleteUserRole(userIds);
    }

    @Override
    public Integer updateUserRole(Long userId, Long roleId) {
        return userRoleMapper.updateUserRole(userId, roleId);
    }

    @Override
    public Long queryRoleCount(Long roleId) {
        return userRoleMapper.queryRoleCount(roleId);
    }
}
